package com.leilei.count;

import cn.hutool.core.util.RandomUtil;
import com.leilei.Location;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

public class MyLocationSource implements SourceFunction<Location> {
    @Override
    public void run(SourceContext<Location> ctx) throws Exception {
        while (true) {
            Location location = Location.builder()
                    .vehicleId(RandomUtil.randomInt(10))
                    .plate("川A0001")
                    .color("黄")
                    .date(20210314)
                    .gpsSpeed(RandomUtil.randomInt(90, 100))
                    .limitSpeed(RandomUtil.randomInt(90, 95))
                    .build();
            Thread.sleep(1000);
            ctx.collect(location);

        }
    }

    @Override
    public void cancel() {

    }
}